------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure7.log
  log type:  text
 opened on:  30 Mar 2017, 13:56:45

. set more off

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      africancabinets_figure7.do                      *;
. *       Date:           September 19, 2016                              *;
. *       Author:         Molly Ariotti and Sona Golder                   *;
. *       Purpose:        Produce Figure 7 in appendix for CPS African    *;
. *                       portfolio allocation paper.                     *;
. *           Input File:     Africa.dta                                      *;
. *       Output File:    figure7.log, nonformateur2.eps                  *;
. *                       formateur2.eps                                  *;
. *       Data Output:    none                                            *;
.              *       Previous file:  none                                            *;
. *       Machine:        laptop                                                          *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Open and summarize dataset.                                     *;
. *     ****************************************************************  *;
. use "\Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta";

.  sum;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 countryname |          0
 countrycode |         84    5.559524    2.552349          1          9
 cabinetcode |         84    13.89286    8.034591          1         28
     cowcode |         84    517.8452    69.14373        403        590
        year |         84    2002.357    6.825965       1990       2014
-------------+---------------------------------------------------------
presidential |         84    .3690476    .4854451          0          1
   formateur |         84    .3095238    .4650739          0          1
  portfolios |         84     7.02381    6.860005          1         26
governmen~os |         84    21.08333    6.637259          9         35
 party_seats |         84    39.91667    56.69368          1        279
-------------+---------------------------------------------------------
governmen~ts |         84    115.0952    86.61028         39        377
      region |         84           1           0          1          1
portfolios~e |         84    .3333333     .282168   .0344828   .9545454
   seatshare |         84    .3333333    .2628826   .0034843    .990099
       party |         84    25.91667    13.80083          1         48
-------------+---------------------------------------------------------
        code |         84    105573.4    2560.162     101001     109028

. desc;

Contains data from \Users\sgolder\Dropbox\Portfolio Allocation\replication\Africa.dta
  obs:            84                          
 vars:            16                          30 Mar 2017 12:13
 size:         4,368                          
------------------------------------------------------------------------------------------------------------------
              storage   display    value
variable name   type    format     label      variable label
------------------------------------------------------------------------------------------------------------------
countryname     str21   %21s                  country name
countrycode     byte    %8.0g                 country code
cabinetcode     byte    %8.0g                 cabinet code
cowcode         int     %8.0g                 cow code
year            int     %8.0g                 year in which government begins
presidential    byte    %8.0g                 1 = presidential, 0 = parliamentary
formateur       byte    %8.0g                 1 = formateur, 0 = otherwise
portfolios      byte    %8.0g                 number of portfolios per party
government_po~s byte    %8.0g                 number of portfolios in the government
party_seats     int     %8.0g                 number of legislative seats per party
government_se~s int     %8.0g                 number of seats controlled by government
region          byte    %8.0g                 1=Africa, 2=Western Europe, 3=Latin America
portfolioshare  float   %9.0g                 party share of govt portfolios
seatshare       float   %9.0g                 party share of leg seats controlled by govt
party           long    %9.0g      party      party number or acronym
code            float   %9.0g                 region, country code, cabinet code
------------------------------------------------------------------------------------------------------------------
Sorted by: 

. *     ****************************************************************  *;
. *       Drop African cabinets where there is no formateur coded.        *;
. *     ****************************************************************  *;
. drop if cabinetcode == 5;
(5 observations deleted)

. drop if cabinetcode == 23;
(3 observations deleted)

. *     ****************************************************************  *;
. *       Create variables for analysis in Table 3                        *;
. *     ****************************************************************  *;
. gen parliamentary = 0;

. replace parliamentary = 1 if presidential == 0;
(45 real changes made)

. label var parliamentary "1 = parliamentary, 0 = presidential";

. gen seatshare_parl= seatshare*parliamentary;

. gen formateur_parl= formateur*parliamentary;

. *     ****************************************************************  *;
. *       Observed range of Seatshare for non-formateur parties.          *;
. *     ****************************************************************  *;
. sum seatshare if formateur==0;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   seatshare |         50    .1848083     .143427   .0034843   .5204082

. *     ****************************************************************  *;
. *       Observed range of Seatshare for formateur parties.              *;
. *     ****************************************************************  *;
. sum seatshare if formateur==1;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
   seatshare |         26    .6445993    .1799418       .312    .990099

. *     ****************************************************************  *;
. *       Table 3, Model 1 Africa                                         *;
. *     ****************************************************************  *;
. regress portfolioshare seatshare formateur parliamentary seatshare_parl formateur_parl, robust;

Linear regression                               Number of obs     =         76
                                                F(5, 70)          =     494.06
                                                Prob > F          =     0.0000
                                                R-squared         =     0.9693
                                                Root MSE          =     .05261

--------------------------------------------------------------------------------
               |               Robust
portfolioshare |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
---------------+----------------------------------------------------------------
     seatshare |   .7736803   .0745152    10.38   0.000     .6250644    .9222962
     formateur |   .2448744   .0494996     4.95   0.000     .1461505    .3435983
 parliamentary |   .0195763   .0170156     1.15   0.254    -.0143603    .0535129
seatshare_parl |    .130125   .0841461     1.55   0.127    -.0376991    .2979491
formateur_parl |  -.1876567   .0549714    -3.41   0.001    -.2972937   -.0780197
         _cons |  -.0065839   .0143996    -0.46   0.649    -.0353029    .0221351
--------------------------------------------------------------------------------

. *     ****************************************************************  *;
. *       Collect the pieces necessary for Fig 6 (Fig2 in the appendix)   *;
. *     ****************************************************************  *;
. matrix b=e(b);

. matrix V=e(V);

. scalar b3=b[1,3];

. scalar b4=b[1,4];

. scalar b5=b[1,5];

. scalar varb3=V[3,3];

. scalar varb4=V[4,4];

. scalar varb5=V[5,5];

. scalar covb3b4=V[3,4];

. scalar covb3b5=V[3,5];

. scalar list b3 b4 b5 varb3 varb4 varb5 covb3b4 covb3b5;
        b3 =  .01957626
        b4 =  .13012501
        b5 = -.18765671
     varb3 =  .00028953
     varb4 =  .00708057
     varb5 =  .00302185
   covb3b4 = -.00090577
   covb3b5 =  .00034431

. *     ****************************************************************  *;
. *       Create values for horizontal axis                               *;
. *     ****************************************************************  *;
. set obs 1000;
number of observations (_N) was 76, now 1,000

. gen MVZ = (_n-1)/1000;

. *     ****************************************************************  *;
. *       Create information for non-formateur parties                    *;
. *     ****************************************************************  *;
. gen marginal_nonformateur = b3+b4*MVZ;

. gen se_nonformateur = sqrt(varb3+varb4*(MVZ^2)+2*MVZ*covb3b4);

. *     ****************************************************************  *;
. *       47 degrees of freedom                                           *;
. *     ****************************************************************  *;
. gen bound = 2.012*se_nonformateur;

. gen upper = marginal_nonformateur+bound;

. gen lower = marginal_nonformateur-bound;

. gen yline=0;

. *     ****************************************************************  *;
. *       Create information for rug plot                                 *;
. *     ****************************************************************  *;
. gen where3=-0.045;

. gen pipe3="|";

. *     ****************************************************************  *;
. *       Produce Figure 6 in appendix, Panel a: Non-formateur parties    *;
. *     ****************************************************************  *;
. graph twoway hist seatshare if formateur==0 & seatshare<0.522, width(0.03) percent color(gs15) yaxis(2)
>     || line marginal_nonformateur MVZ if MVZ<0.522 & MVZ>0.002, clpattern(solid) clwidth(medthick) clcolor(black
> ) yaxis(1)
>     || line lower MVZ if MVZ>0.002 & MVZ<0.522, clpattern(dash) clwidth(thin) clcolor(red)
>     || line upper MVZ if MVZ>0.002 & MVZ<0.522, clpattern(dash) clwidth(thin) clcolor(red)
>     || line yline MVZ, clpattern(solid) clwidth(thin) clcolor(black)
>     || scatter where3 seatshare if formateur==0, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe3) mlabpos(6)
>     ||,
>     xlabel(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0, nogrid labsize(2.5))
>     ylabel( -0.05 0 0.05 0.10 0.15 0.20 0.25, axis(1) nogrid labsize(2.5))
>     ylabel(0 3 6 9 12 15, axis(2) nogrid labsize(2.5) labcolor(gs12) tlcolor(gs12))
>         yscale(noline alt)
>         yscale(noline alt axis(2))
>         xscale(noline)
>         legend(off)
>         title("{stSerif:(a) Non-Formateur Parties}",  size(3.5))
>         xtitle("{stSerif:Share of Government's Legislative Seats}",  size(3) height(7) )
>         ytitle("{stSerif:Percentage of Observations}", color(gs12) axis(2) size(3) margin(5 0 0 0))
>         ytitle("{stSerif:Marginal Effect of Africa}", size(3) height(7)) 
>         scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));

.                                           graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replicatio
> n\nonformateur2.eps", replace;
(file C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\nonformateur2.eps written in EPS format)

. *     ****************************************************************  *;
. *       Calculating percentage of observations that fall in region of   *;
. *       significance 37/50 = 74%                                        *;
. *     ****************************************************************  *;
. list countryname cabinetcode year seatshare if seatshare>0.065 & formateur==0;

      +----------------------------------------------------+
      |           countryname   cabine~e   year   seatsh~e |
      |----------------------------------------------------|
   2. |               Burundi          1   2005   .1351351 |
   4. |               Burundi          1   2005   .2702703 |
   6. |               Burundi          2   2007   .2752294 |
   7. |               Burundi          2   2007   .1376147 |
  10. |               Burundi          3   2010   .1650485 |
      |----------------------------------------------------|
  14. |         Guinea-Bissau          6   2007   .1752577 |
  15. |         Guinea-Bissau          6   2007   .3608247 |
  17. |                 Kenya          7   2003       .168 |
  18. |                 Kenya          7   2003       .472 |
  20. |                 Kenya          8   2004   .0697674 |
      |----------------------------------------------------|
  21. |                 Kenya          8   2004   .3162791 |
  23. |                 Kenya          9   2008   .1702128 |
  25. |                 Kenya         10   2008   .0816327 |
  26. |                 Kenya         10   2008   .5204082 |
  28. |               Lesotho         11   2012   .0819672 |
      |----------------------------------------------------|
  29. |               Lesotho         11   2012   .4262295 |
  32. |                Malawi         12   1994   .2975207 |
  33. |                Malawi         13   2004   .0857143 |
  34. |                Malawi         13   2004   .2142857 |
  37. |                Malawi         14   2014     .21875 |
      |----------------------------------------------------|
  39. |             Mauritius         15   1990    .362069 |
  41. |             Mauritius         15   1990   .1551724 |
  43. |             Mauritius         16   1991    .440678 |
  47. |             Mauritius         17   1995   .4193548 |
  52. |             Mauritius         18   1995   .4166667 |
      |----------------------------------------------------|
  53. |             Mauritius         19   2010   .0851064 |
  56. |             Mauritius         19   2010   .2553191 |
  58. |             Mauritius         20   2014   .2156863 |
  59. |             Mauritius         20   2014   .1372549 |
  61. | Sao Tome and Principe         21   1996   .3414634 |
      |----------------------------------------------------|
  63. | Sao Tome and Principe         22   1996   .2051282 |
  65. | Sao Tome and Principe         24   2002   .4181818 |
  66. | Sao Tome and Principe         24   2002   .1454545 |
  68. |          South Africa         25   1994   .1140584 |
  69. |          South Africa         25   1994   .2175066 |
      |----------------------------------------------------|
  70. |          South Africa         26   1996   .1457627 |
  72. |          South Africa         27   1999   .1133333 |
      +----------------------------------------------------+

. sum cabinetcode if formateur==0;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 cabinetcode |         50        13.9    7.874656          1         28

. *     ****************************************************************  *;
. *       Create information for formateur parties                        *;
. *     ****************************************************************  *;
.               gen marginal_formateur = b3+b4*MVZ + b5;

. gen se_formateur = sqrt(varb3+varb4*(MVZ^2)+2*MVZ*covb3b4 + varb5+2*covb3b5);

. *     ****************************************************************  *;
. *       47 degrees of freedom                                           *;
. *     ****************************************************************  *;
. gen bound2 = 2.012*se_formateur;

. gen upper2 = marginal_formateur+bound2;

. gen lower2 = marginal_formateur-bound2;

. *     ****************************************************************  *;
. *       Create information for rug plot                                 *;
. *     ****************************************************************  *;
. gen where2=-0.3;

. gen pipe2="|";

. *     ****************************************************************  *;
. *       Produce Figure 6 in appendix, Panel b: Formateur parties        *;
. *     ****************************************************************  *;
. graph twoway hist seatshare if formateur==1 & seatshare<0.99 & seatshare>0.3, width(0.03) percent color(gs15) ya
> xis(2)
>     || line marginal_formateur MVZ if MVZ<0.99 & MVZ>0.3, clpattern(solid) clwidth(medthick) clcolor(black) yaxi
> s(1)
>     || line lower2 MVZ if MVZ<0.99 & MVZ>0.3, clpattern(dash) clwidth(thin) clcolor(red)
>     || line upper2 MVZ if MVZ<0.99 & MVZ>0.3, clpattern(dash) clwidth(thin) clcolor(red)
>     || line yline MVZ, clpattern(solid) clwidth(thin) clcolor(black)
>     || scatter where2 seatshare if formateur==1, plotr(m(b 4)) ms(none) mlabcolor(gs5) mlabel(pipe2) mlabpos(6)
>     ||,
>     xlabel(0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0, nogrid labsize(2.5))
>     ylabel(-0.3 -0.2 -0.1 0 0.10 0.20 0.3, axis(1) nogrid labsize(2.5))
>     ylabel(0 2 4 6 8 10 12, axis(2) nogrid labsize(2) labcolor(gs12) tlcolor(gs12))
>         yscale(noline alt)
>         yscale(noline alt axis(2))
>         xscale(noline)
>         legend(off)
>         title("{stSerif:(b) Formateur Parties}",  size(3.5))
>         xtitle("{stSerif:Share of Government's Legislative Seats}",  size(3) height(7) )
>         ytitle("{stSerif:Percentage of Observations}", color(gs12) axis(2) size(3) margin(5 0 0 0))
>         ytitle("{stSerif:Marginal Effect of Africa}", size(3) height(7)) 
>         scheme(s2mono) graphregion(fcolor(white) ilcolor(white) lcolor(white));

.                     graph export "C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\formateur2.eps", rep
> lace;
(file C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\formateur2.eps written in EPS format)

. list countryname cabinetcode year seatshare if seatshare<0.303 & formateur==1;

. sum cabinetcode if formateur==1;

    Variable |        Obs        Mean    Std. Dev.       Min        Max
-------------+---------------------------------------------------------
 cabinetcode |         26    14.53846    8.159563          1         28

. log close;
      name:  <unnamed>
       log:  C:\Users\sgolder\Dropbox\Portfolio Allocation\replication\figure7.log
  log type:  text
 closed on:  30 Mar 2017, 13:56:47
------------------------------------------------------------------------------------------------------------------
